﻿using System;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;

namespace UCCustom
{
    public partial class JanelaBase : Window
    {
        public VisualCollection _conteudosVisiveis;

        public JanelaBase()
        {
            _conteudosVisiveis = new VisualCollection(this);
        }

        protected override void OnSourceInitialized(EventArgs e)
        {
            base.OnSourceInitialized(e);

            CarregarConteudosVisiveis(ControlesFormularioBase);
        }

        //

        public static readonly DependencyProperty MainMenuProperty =
            DependencyProperty.Register("MainMenu", typeof(Panel), typeof(JanelaBase), new PropertyMetadata(default(object)));

        public Panel MainMenu
        {
            get { return (Panel)GetValue(MainMenuProperty); }
            set { SetValue(MainMenuProperty, value); }
        }

        public static readonly DependencyProperty ControlesFormularioBaseProperty = DependencyProperty.Register("ControlesFormularioBase", typeof(Panel), typeof(JanelaBase), new PropertyMetadata(default(object)));
        public Panel ControlesFormularioBase
        {
            get { return (Panel)GetValue(ControlesFormularioBaseProperty); }
            set { SetValue(ControlesFormularioBaseProperty, value); }
        }


        //

        public void CarregarConteudosVisiveis(params Visual[] objetoComponente)
        {
            foreach (var visual in objetoComponente)
            {
                _conteudosVisiveis.Add(visual);
            }
        }

        //

        protected override Visual GetVisualChild(int index)
        {
            return _conteudosVisiveis[index];
        }
        protected override int VisualChildrenCount
        {
            get { return _conteudosVisiveis.Count; }
        }

        //protected override Size ArrangeOverride(Size arrangeBounds)
        //{
        //    foreach (var visual in _conteudosVisiveis)
        //    {
        //        (visual as UIElement).Arrange(new Rect(arrangeBounds));
        //    }

        //    return base.ArrangeOverride(arrangeBounds);
        //}
    }
}
